package com.example.springai.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.springai.common.R;
import com.example.springai.domain.AiDocumentChunk;
import com.example.springai.mapper.AiDocumentChunkMapper;
import com.example.springai.service.IAiDocumentChunkService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * AI文档块服务实现类
 *
 * @author ZWX
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class AiDocumentChunkServiceImpl extends ServiceImpl<AiDocumentChunkMapper, AiDocumentChunk> implements IAiDocumentChunkService {

    /**
     * 根据文档ID获取文档块列表
     *
     * @param documentId 文档ID
     * @return 文档块列表
     */
    @Override
    public List<AiDocumentChunk> getByDocumentId(Long documentId) {
        LambdaQueryWrapper<AiDocumentChunk> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AiDocumentChunk::getDocumentId, documentId);
        return list(queryWrapper);
    }
}
